<script setup>
import { ref } from "vue";
import { useRoute } from "vue-router";
import { getSearchList } from "../../apis/music";
import { createWindow } from "../../utils/ipcRenderer";

const route = useRoute();
const loading = ref(false)
const albumList = ref([]);
const getInit = async () => {
  loading.value = true
  let res2 = await getSearchList(route.params.keyword, 20, 0, 100);
  console.log(res2);
  albumList.value = res2.result.artists;
  loading.value = false
};
getInit();

const handleSinger = (id) => {
  createWindow({
    windowName: "singerDetail",
    path: "singerDetail",
    width: 1200,
    height: 820,
    param: { id: id },
  });
};
</script>
<template>
  <div v-loading="loading" class="singer_album">
    <el-scrollbar heigt="100%">
      <div class="title">搜索 艺人 "{{ route.params.keyword }}"</div>
      <div class="item_wrap">
        <div v-for="(item, index) in albumList" :key="index" class="item">
          <div v-if="item.picUrl" class="cover">
            <!-- <img :src="item.picUrl" alt=""> -->
            <el-image
              lazy
              @click="handleSinger(item.id)"
              :src="item.img1v1Url+`${'?param=300y300'}`"
              fit="cover"
            >
              <template #placeholder>
                <div class="image-slot">
                  Loading<span class="dot">...</span>
                </div>
              </template></el-image
            >
          </div>
          <div class="name">{{ item.name }}</div>
        </div>
      </div>
    </el-scrollbar>
  </div>
</template>

<style lang="scss" scoped>
.singer_album {
  height: 100%;
  .title {
    font-size: 30px;
    height: 40px;
    line-height: 40px;
    margin-bottom: 40px;
    font-weight: 600;
  }
  .item_wrap {
    display: grid;
    justify-content: space-around;
    grid-template-columns: repeat(auto-fill, 16vw);
  }
  .item {
    margin-bottom: 3rem;

    .cover {
      width: 15vw;
      height: 15vw;
      .el-image {
        width: 100%;
        height: 100%;
        border-radius: 50%;
      }
    }
    .name {
      text-align: center;
      font-size: 18px;
      font-weight: 600;
      margin-top: 10px;
    }
  }
}
</style>
